
<template>
  <el-container>
    <el-header>
      <div style="padding-left: 65%">
      <el-button type="primary" @click="toudi">简历投递<i class="el-icon-upload el-icon&#45;&#45;right"></i></el-button>
      <el-button type="primary" icon="el-icon-star-on" v-if="flag =='0' && type == 'maininfo' " @click="ycollect">收藏</el-button>
        <el-button type="primary" icon="el-icon-star-on" v-if="srb=='0'" @click="ycollect">收藏</el-button>
      <el-button type="danger" icon="el-icon-star-on" v-if="type == 'collect'" @click="ncollect">取消收藏</el-button>
        <el-button type="danger" icon="el-icon-star-on" v-if="flag == '1'" @click="ncollect">取消收藏</el-button>
      </div>
    </el-header>
    <div style="width: 80%;padding-left: 10%;margin-top: 20px" >
    <el-container>
      <el-aside  width="80%;">
        <div class="demo-fit" style="margin-top: 20px;text-align: center">
          <div class="block">
            <el-avatar shape="square" :size="100" :src="dz+url"></el-avatar>
          </div>
          <h1 style=" text-align: center;">{{workinfo.enterInfo.principal}}</h1>
          <h4  style=" text-align: center;">{{workinfo.enterInfo.cname}} / {{workinfo.gw}}</h4>
        </div>

        <div class="srca">
          <h3>
            <i class="fa fa-user" aria-hidden="true"></i>基本信息</h3>
          <hr/>
          <ul>
            <li>
              <label>上市情况：</label>
              <span>{{workinfo.enterInfo.listing}}</span>
            </li>
            <li>
              <label>公司人数：</label>
              <span>{{workinfo.enterInfo.people}}</span>
            </li>
            <li>
              <label>岗位属性：</label>
              <span>{{workinfo.type}}</span>
            </li>
          </ul>
        </div>
        <div class="srca">
          <h3>
            <i class="fa fa-phone-square" aria-hidden="true"></i>联系方式</h3>
          <hr/>
          <ul>
            <li>
              <label>手机：</label>
              <span>{{workinfo.enterInfo.tel}}</span>
            </li>
            <li>
              <label>邮箱：</label>
              <span>{{workinfo.enterInfo.tel}}</span>
            </li>
          </ul>
        </div>
        <div class="srca">
          <h2>
            <i class="fa fa-gear" aria-hidden="true"></i>公商信息</h2>
          <hr/>
          <ul>
            <li>
              <label>公司名称：</label>
              <span >{{workinfo.enterInfo.cname}}</span>
            </li>
            <li>
              <label>法人代表：</label>
              <span >{{workinfo.enterInfo.legal}}</span>
            </li>
            <li>
              <label>注册资金：</label>
              <span >{{workinfo.enterInfo.money}}</span>
            </li>
            <li>
              <label>成立时间：</label>
              <span >{{workinfo.enterInfo.time}}</span>
            </li>
            <li>
              <label>企业类型：</label>
              <span >{{workinfo.enterInfo.attribute}}</span>
            </li>
            <li>
              <label>经营状态：</label>
              <span >{{workinfo.enterInfo.status}}</span>
            </li>
          </ul>
        </div>
      </el-aside>
      <el-main>
        <div>
          <div>
            <h3>
              <i class="fa fa-laptop" aria-hidden="true"></i>职位描述</h3>
            <hr/>
            <ul>
              <li>
                <h3>
                  <span>工作职责</span>
                </h3>
                <p v-html="workinfo.opera"></p>
              </li>
              <li>
                <h3>
                  <span>任职要求</span>
                </h3>
                <p v-html="workinfo.claim"></p>
              </li>
            </ul>
          </div>
          <div class="work info-unit">
            <h3>
              <i class="fa fa-institution" aria-hidden="true"></i>公司介绍</h3>
            <hr/>
            <ul class="info-content">
              <li style="list-style-type:none;">
                <p v-html="workinfo.enterInfo.info">
                </p>
              </li>
            </ul>
          </div>
          <div class="work info-unit">
            <h3>
              <i class="fa fa-globe" aria-hidden="true"></i>详细地址：</h3>
            <hr/>
            <div class="location-address">{{workinfo.address.detailaddr}}</div>
            <div class="amap-wrapper">
             <el-amap class="amap-box" :vid="'amap-vue'" :center="[log,loh]" :zoom="zoom"></el-amap>
            </div>
          </div>
        </div>
      </el-main>
    </el-container>
      <el-dialog title="简历上传" :visible.sync="file_state" style="width: 900px;padding-left: 26%">
          <el-upload
              class="upload-demo"
              ref="upload"
              :auto-upload="false"
              :http-request="upLoadFile"
              :multiple="multiple"
              :limit="Number(1)"
              accept=".doc,.docx, .pdf,"
              drag
              action=""
          >
            <i class="el-icon-upload"></i>
            <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
            <div class="el-upload__tip" slot="tip">只能上传doc、docx 、pdf格式文件，且不超过10MB</div>
          </el-upload>
          <div align="center">
            <el-button
                type="success"
                size="small"
                @click="add()"
            >确认</el-button>
          </div>
      </el-dialog>
    </div>
  </el-container>
</template>


<script>

export default {

  name: "EnterInfo",
  data(){
    return {
      file_state:false,
      flag : "",
      srb:"1",
      type:this.$route.query.type,
      log: "",
      loh: "",
      zoom: 20,//初始化地图显示层级
      mapStyle: "amap://styles/8b6be8ec497009e17a708205348b899a", //设置地图样式
      workinfo: {},
      wid: this.$route.query.wid,
      tid: this.$route.query.tid,
      url: "",
      dz:this.$axios.defaults.baseURL,
      claim: "",
      opera: "",
      count: 1,
      slotStyle: {
        padding: '2px 8px',
        background: '#eee',
        color: '#333',
        border: '1px solid #aaa'
      },
    }
  },
  methods:{
    upLoadFile(file){
      this.formData.append("files",file.file)
    },
  toudi(){
    this.file_state = true;
    console.log(sessionStorage.getItem("tuid"));
  },
    add(){
      this.formData = new FormData();
      this.formData.append("uid",sessionStorage.getItem("studentuid"));
      this.formData.append("tid",this.tid);
      this.formData.append("wid",this.wid);
      this.formData.append("tuid",sessionStorage.getItem("tuid"));
      this.formData.append("gw",this.workinfo.gname);
      this.$refs.upload.submit();
      this.$axios.post(this.$axios.defaults.baseURL+"/enterprise/fileupload",this.formData,{
        headers: {'Content-Type': 'multipart/form-data'
        }}).then(res => {
        if (res.status) {
          this.$message.success(res.data.msg);
        } else {
          this.$message.error(res.data.msg);
        }
        setTimeout(() => {
          this.file_state = false;
          if(res.status){
            this.myselfinfo();
          }
        }, 1500);
      })
    },
    ycollect(){
      this.$axios({
        url: this.$axios.defaults.baseURL+"/student/insertcollect",
        method: "get",
        params:{
          wid : this.wid,
          tid : this.tid,
          uid:sessionStorage.getItem("studentuid")
        }
      }).then(res => {
        if(res.data.status){
          this.$message.success(res.data.msg);
          this.enterinfo()
        }else{
          this.$message.error(res.data.msg);
        }
      })
    },
    ncollect(){
      this.$axios({
        url: this.$axios.defaults.baseURL+"/student/deleteCollect",
        method: "get",
        params:{
          wid : this.wid,
          tid : this.tid,
          uid:sessionStorage.getItem("studentuid")
        }
      }).then(res => {
        if(res.data.status){
          this.$message.success(res.data.msg);
          this.srb = "0";
          this.enterinfo()
        }else{
          this.$message.error(res.data.msg);
        }
      })
    },
    enterinfo(){
      if(this.type!=null && this.type=="maininfo"){
        this.$axios({
          url: this.$axios.defaults.baseURL+"/student/maininfo",
          method: "get",
          params:{
            wid : this.wid,
            tid : this.tid,
            uid:sessionStorage.getItem("studentuid")
          }
        }).then(res => {
          this.workinfo = res.data;
          this.flag = res.data.staclloct;
          this.log = res.data.address.location.split(",")[0];
          this.loh = res.data.address.location.split(",")[1];
          this.url = res.data.enterInfo.logoimg;
        })
      }else {
        this.$axios({
          url: this.$axios.defaults.baseURL+"/student/selectworkinfo",
          method: "get",
          params:{
            wid : this.wid,
            tid : this.tid
          }
        }).then(res => {
          this.workinfo = res.data;
          this.flag = res.data.staclloct;
          this.url = res.data.enterInfo.logoimg;
          this.log = res.data.address.location.split(",")[0];
          this.loh = res.data.address.location.split(",")[1];
        })
      }

    },
  },
  mounted() {
    this.enterinfo();

  }
}
</script>

<style scoped>

.el-header, .el-footer {
  background-color: #B3C0D1;
  color: #333;
  line-height: 60px;
}
.amap-wrapper {
  width: 800px;
  height: 200px;
}
.el-aside {
  color: #333;
  font-family: Arial;
  border-radius: 5px 5px 5px 5px;
  width: 20%;
  background-color: white;
}

.el-main {
  background-color: white;
  color: #333;
  margin-left: 10px;
  border-radius: 5px 5px 5px 5px;
}
.srca{
  margin-top: 10px;
  margin-left: 10px;
}

body > .el-container {
  margin-bottom: 40px;
}

.el-container:nth-child(5) .el-aside,
.el-container:nth-child(6) .el-aside {
  line-height: 260px;
}

.el-container:nth-child(7) .el-aside {
  line-height: 320px;
}

li{
  margin-top: 8px;
  list-style: none;
}
</style>
